home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Allocation of memory
- Date: 4 Feb 1996 07:56:24 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4f2kv8INNlql@keats.ugrad.cs.ubc.ca>
- References: <4evre9$8r4@news.rz.uni-passau.de>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
- Keywords: realloc
-
- In article <4evre9$8r4@news.rz.uni-passau.de>,
- Klaus Berndl <berndl@piligrim.uni-passau.de> wrote:
- >2) With ALLOCSIZE set to 100000000 the program works correct. But if i set
- > ALLOCSIZE to 300000000, i reach the following output:
- >
- > Klaus
- >
- > t-realloc failed
- >
- > test1
- > Bus Error (core dumped)
- >
- > What is 'realloc' doing exactly? Normally if realloc can`t allocate the
- > requested memory it returns NULL and doesn`t allocate memory. Why the
- > second realloc-call (x = ...) fails? There must be 1000000 Byte memory
- > because of the first try with ALLOCSIZE 100000000 works!
-
- This is not clear. At first you say that the program works correctly with
- ALLOCSIZE set to 10^8. This contradicts your assertion that the second
- realloc() call fails.
-
- By the way, how is it guaranteed that an allocation of 10^6 bytes will succeed
- just because a previous allocation of 10^8 bytes succeeded? This is a fallacy,
- since if I took it as an inductive hypothesis, I would come to the conclusion
- that I can allocate any amount of memory I want. (I can allocate one byte.
- Given that I have allocated n bytes, I surely can allocate an extra byte to get
- n + 1 bytes. Therefore I can allocate any number of bytes I want.)
-
- All we know is that you can get 10^8 bytes, and that you cannot get 3 * 10^8
- bytes. Thus the actual amount you _can_ get is somewhere between these two
- limits in a 2 * 10^8 range. Assuming that the actual limit is randomly
- determined in this range, your probability of not being able to allocate
- another megabyte out of the 200 is about 1/200, so I could see where your
- surprise comes from. :) Of course, you don't know where the actual limit lies.
-
- It could be that your program (under your typical working load conditions) is
- able to get 100MB, which gets you just within a megabyte of virtual memory
- exhaustion. Or it could be that the malloc() routines are simply broken.
-
- Also, do you have limits set on process size? That could also bite you.
- --
-
-